
#include "global_config.h"

#define TAG "app_btn"

static void app_btn_event (btn_event_t event) {
    // esay_logi(TAG, "btn event:%d", event);
    static uint8_t sat = 0X01;
    if (event == btn_click) {
        // sat = !sat;
        // if (sat)
        // drv_key_send_event(sat);
        // sat <<= 1;
        // if(sat == 0x80)
        //     sat = 0x01;
        // else
        // gpio_set_level(SF32_EN, !gpio_get_level(SF32_EN));

        topic_messenger_msg ("key_lock", NULL, 0);

        return;
    }

    if (event == btn_double_click) {
        topic_messenger_msg ("key_unlock", NULL, 0);
        return;
    }

    if (event == btn_long_press) {
        sat = !sat;
        if (sat)
            topic_messenger_msg ("usb_conn", NULL, 0);
        else
            topic_messenger_msg ("usb_disconn", NULL, 0);
        return;
    }
}

void app_btn_install (void) {
    topic_messenger_msg ("btn_set_event_cb", app_btn_event, 0);
}
